//package com.woniu.controller;
//
//import com.jcraft.jsch.JSchException;
//import com.jcraft.jsch.SftpException;
//import com.woniu.service.AudioProcessingService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.io.FileSystemResource;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.http.codec.multipart.FilePart;
//import org.springframework.web.bind.annotation.*;
//import reactor.core.publisher.Mono;
//
//import java.io.IOException;
//
//@RestController
//@RequestMapping("/api/media")
//public class MediaController {
//
//    @Autowired
//    private AudioProcessingService audioProcessingService;
//
//    @PostMapping("/convert")
//    public Mono<ResponseEntity<FileSystemResource>> convertVideoToAudio(
//            @RequestPart("file") FilePart videoFile) throws JSchException, SftpException, IOException {
//
//        return audioProcessingService.processVideoToAudio(videoFile)
//                .map(audioFile -> {
//                    // 成功转换后返回文件
//                    return ResponseEntity.ok()
//                            .header(HttpHeaders.CONTENT_DISPOSITION,
//                                    "attachment; filename=\"" + audioFile.getName() + "\"")
//                            .contentType(MediaType.parseMediaType("audio/mpeg"))
//                            .body(new FileSystemResource(audioFile));
//                })
//                .onErrorResume(e -> {
//                    // 错误处理
//                    return Mono.error(new RuntimeException("转换失败: " + e.getMessage(), e));
//                });
//    }
//}